package org.nimi317.web_gis.utils;

import java.util.List;
import java.util.Map;
import java.util.function.Function;

/**
 * @author thunderobot
 */
public class MapUtils {

    /**
     * 将列表转化为map
     */
    public static <T> Map<Object, Object> listToMap(List<T> list, Function<T, ?> method) {
        Map<Object, Object> map = new java.util.HashMap<>();
        for (T t : list) {
            map.put(method.apply(t), t);
        }
        return map;
    }
}
